package com.kws.system.controller.merchant;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kws.common.core.domain.R;
import com.kws.system.domain.merchant.MerchantExamineRq;
import com.kws.system.domain.merchant.QueryServerRq;
import com.kws.system.domain.merchant.info.QueryServerExamineInfo;
import com.kws.system.domain.merchant.info.QueryServerInfo;
import com.kws.system.service.merchant.ServeManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <b>ServeManagementController</b>
 *
 * @description: ServeManagementController <br>
 * @date: 2024/12/5 15:35 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "服务上架审核模块")
@RestController
public class ServeManagementController {
    private static final Logger logger = LoggerFactory.getLogger(ServeManagementController.class);

    @Autowired
    private ServeManagementService serveManagementService;

    @ApiOperation("分页查询服务列表")
    @PostMapping("/query/serverPage")
    public R<Page<QueryServerInfo>> queryServerPage(@RequestBody QueryServerRq rq){
        Page<QueryServerInfo> pageInfo = serveManagementService.queryServerPage(rq);
        return R.ok(pageInfo);
    }

    @ApiOperation("根据服务ID查询服务详情")
    @GetMapping("/query/serverAudit/byId")
    public R<QueryServerExamineInfo> queryServerAuditById(@RequestParam Long id){
        QueryServerExamineInfo info = serveManagementService.queryServerAuditById(id);
        return R.ok(info);
    }

    @ApiOperation("根据服务ID删除服务")
    @GetMapping("/delete/serverById")
    public R deleteServerById(@RequestParam Long id){
        boolean status = serveManagementService.deleteServerById(id);
        return R.ok(status);
    }

    @ApiOperation("服务商家一审")
    @PostMapping("/serverAudit/firstInstance")
    public R serverAuditFirstInstance(@RequestBody MerchantExamineRq rq){
        boolean status = serveManagementService.serverAuditFirstInstance(rq);
        return R.ok(status);
    }

    @ApiOperation("服务商家二审")
    @PostMapping("/serverAudit/secondInstance")
    public R serverAuditSecondInstance(@RequestBody MerchantExamineRq rq){
        boolean status = serveManagementService.serverAuditSecondInstance(rq);
        return R.ok(status);
    }
}
